package com.wuseguang.springcloud.controller;


import com.wuseguang.springcloud.Filter.RequestParameterWrapper;
import com.wuseguang.springcloud.entity.OiCountdown;
import com.wuseguang.springcloud.service.OiCountdownService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 事件倒计时 前端控制器
 * </p>
 *
 * @author 
 * @since 2020-06-30
 */
@RestController
@RequestMapping("/jurisdiction")
public class OiCountdownController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private OiCountdownService oiCountdownServiceImpl;

    /**
     * 添加事件倒计时
     * @param request
     * @param oiCountdown
     * @return
     */
    @RequestMapping("/addOiCountdown")
    public Result  addOiCountdown(RequestParameterWrapper request, OiCountdown oiCountdown){
        logger.info("添加事件倒计时");
        return oiCountdownServiceImpl.addOiCountdown(oiCountdown);
    }

    /**
     * 按班级查询事件倒计时记录
     * @param request
     * @param classId
     * @return
     */
    @RequestMapping("/findClassOiCountdown")
    public Result findClassOiCountdown(RequestParameterWrapper request,
                                       @RequestParam(value = "classId",required = false) Integer classId,
                                       @RequestParam(value = "indexNo", required = false, defaultValue = "1") Integer indexNo,
                                       @RequestParam(value = "rows", required = false, defaultValue = "20") Integer rows){
        logger.info("按班级查询事件倒计时记录");
        if(StringUtils.isEmpty(classId)){
            return new Result();
        }
        return oiCountdownServiceImpl.findClassOiCountdown(classId,indexNo,rows);
    }

    /**
     * 事件倒计时删除
     * @param request
     * @param id 事件倒计时id
     * @return
     */
    @RequestMapping("/deleteOiCountdown")
    public Result deleteOiCountdown(RequestParameterWrapper request,
                                    @RequestParam(value = "id") Integer id){
        logger.info("事件倒计时删除");
        return oiCountdownServiceImpl.deleteOiCountdown(id);
    }

    /**
     * 事件置顶
     * @param request
     * @param id 事件倒计时id
     * @return
     */
    @RequestMapping("/OiCountdownTopping")
    public Result OiCountdownTopping(RequestParameterWrapper request,
                                     @RequestParam(value = "id") Integer id,
                                     @RequestParam(value = "classId") Integer classId){

        logger.info("事件置顶");
        return oiCountdownServiceImpl.OiCountdownTopping(id,classId);
    }

    /**
     * 取消置顶
     * @param request
     * @param id 事件倒计时id
     * @return
     */
    @RequestMapping("/oiCountdownCancelTopping")
    public Result oiCountdownCancelTopping(RequestParameterWrapper request,
                                           @RequestParam(value = "id") Integer id){
        logger.info("事件取消置顶");
        return oiCountdownServiceImpl.oiCountdownCancelTopping(id);
    }


}

